package au.com.handsunited.model.propertyeditors;

import java.beans.PropertyEditorSupport;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.com.handsunited.model.relationship.RelationshipStatus;


/**
 * @author arunda
 *
 */
public class RelationshipStatusEditor extends PropertyEditorSupport {

	private static Logger logger = LoggerFactory.getLogger(RelationshipStatusEditor.class);

	/**
	 *
	 */
	public RelationshipStatusEditor() {
	}

	/**
	 * @param source
	 */
	public RelationshipStatusEditor(Object source) {
		super(source);
	}


	/**
	 * @see java.beans.PropertyEditorSupport#getAsText()
	 */
	@Override
	public String getAsText() {
		if (getSource() == null) {
			return "";
		} else {
			return super.getAsText();
		}
	}

	/**
	 * @see java.beans.PropertyEditorSupport#getValue()
	 */
	@Override
	public Object getValue() {

		return super.getValue();
	}

	/**
	 * @see java.beans.PropertyEditorSupport#setAsText(java.lang.String)
	 */
	@Override
	public void setAsText(String text) throws IllegalArgumentException {

		RelationshipStatus status = RelationshipStatus.fromString(text);
		setValue(status);
	}

}
